import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

class FilterBackLayerLayout extends HookWidget {
  final Widget child;
  final VoidCallback onClear;
  final VoidCallback onConfirm;

  const FilterBackLayerLayout({
    Key? key,
    required this.child,
    required this.onClear,
    required this.onConfirm,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Expanded(
          child: SingleChildScrollView(
            child: child,
          ),
        ),
        Padding(
          padding:
              const EdgeInsets.only(left: 16, right: 16, bottom: 48, top: 24),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              ElevatedButton(
                onPressed: onClear,
                child: const Text("清空"),
              ),
              ElevatedButton(
                onPressed: onConfirm,
                style: ElevatedButton.styleFrom(
                  backgroundColor: Theme.of(context).colorScheme.primary,
                  foregroundColor: Theme.of(context).colorScheme.onPrimary,
                ),
                child: Text(
                  "应用",
                  style:
                      TextStyle(color: Theme.of(context).colorScheme.onPrimary),
                ),
              ),
            ]
                .map((e) => Padding(
                      padding: const EdgeInsets.only(
                        left: 8,
                      ),
                      child: e,
                    ))
                .toList(),
          ),
        ),
      ],
    );
  }
}
